<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>选择父分类</title>
	<script type="text/javascript" src="../js/jquery/jquery.js"></script>
	<script type="text/javascript" src="../js/jquery/jquery.cookie.js"></script>
	<script type="text/javascript" src="../js/jquery/jquery.hotkeys.js"></script>
	<script type="text/javascript" src="../js/jstree/jquery.jstree.js"></script>
	<script type="text/javascript" src="../js/treeChooseCatalog.js"></script>

	<style type="text/css">
	html, body { width:100%;height:100%; margin:0; padding:0; overflow:hidden; }
	body, td, th, pre, code, select, option, input, textarea { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; }
	.jsTree, .jsTree input, .jstree-dnd-helper, #vakata-contextmenu { font-size:12px; font-family:Verdana; }
	#container { width:auto; margin:10px auto; overflow:hidden; position:relative; }
	#jsTree { width:100%; float:left; margin:0; border:0px solid gray; background:white; overflow:auto; }

	#text { margin-top:1px; }

	#alog { font-size:9px !important; margin:5px; border:1px solid silver; }
	</style>

	<script language="javascript">
	function GetUrlParameter(name) {
		var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
		var r = window.location.search.substr(1).match(reg);
		if (r!=null)
			return unescape(r[2]);
		return null;
	}  
	function doAction(action){
		id=getNodeID();
		if (id==null) {
			alert("请选择一个父分类！");
			return;
		}

		if (action == "confirm") {
			opener.setParentCatalog(id, $("#jsTree").jstree("get_text", "#"+id));
			self.close();
		}
	}

	function getNodeID() {
		var pNodeID = null;
		var nodes = $.jstree._reference($("#jsTree")).get_selected();
		$.each(nodes, function(i, n) {
			pNodeID=n.id;
			return false;
		});
		return pNodeID;
	}

	function getWindowHeight() {
		if (window.innerHeight)
			return winHeight = window.innerHeight;
		else if ((document.body) && (document.body.clientHeight))
			return winHeight = document.body.clientHeight;
	}

	function jsTreeResize(obj) {
		var oWatermark = document.getElementById("jsTree");
		oWatermark.style.height = (getWindowHeight()-40)+"px";
	}
	window.onload = function() {
		window.onresize = jsTreeResize;
		jsTreeResize();
	}

	</script>
</head>
<body>
</body>
<!-- the tree container (notice NOT an UL node) -->
<div id="jsTree" class="jsTree"></div>

<div style="height:40px; text-align:center;">
  <input type="button" style='width:80px; height:24px; margin:8px;' value="确定" onclick="doAction('confirm');" />
  <input type="button" style='width:80px; height:24px; margin:8px;' value="取消" onclick="self.close();" />
</div>

</html>